﻿using System;
using System.Web.Mvc;
using System.Web.Routing;

namespace Sample.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Sample",
                "Sample/{id}",
                new { controller = "Home", action = "Index", id = "" },
                new { id = @"\d+", httpMethod = new HttpMethodConstraint("GET") }
            );

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" } // Parameter defaults,
            );
        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
            AddApplicationValuesForTestingPurposes();
        }

        private void AddApplicationValuesForTestingPurposes()
        {
            Application["StartTime (DateTime)"] = DateTime.Now;
            Application["Name (String)"] = "Isis Sample";
            Application["Meaning Of Life, The Universe, and Everything (int)"] = 42;
            Application["Complex Data Type (Routes)"] = RouteTable.Routes;

        }

    }
}